Sets the BulkData with a byte array.
public void SetBulkData(
byte[] byteArray
)
public:
void SetBulkData(
array<Byte>^ byteArray
)
byteArray
a byte array representing the BulkData
There are four ways to modify the BulkData:
using Leadtools.Dicom;
using Leadtools.Dicom.Common;
using Leadtools.Dicom.Common.Extensions;
using Leadtools;
using Leadtools.Dicom.Common.Linq.BasicDirectory;
using Leadtools.Dicom.Common.DataTypes;
using Leadtools.Codecs;
public static class SetBulkDataExample
{
public static bool MyLoadJsonBeforeElementCallback(LoadJsonBeforeElementData elementData)
{
// You can change the TransferSyntax here to any valid TransferSyntax
// Setting the TransferSyntax ElementValue to empty defaults the transfer syntax to Explicit VR Little Endian
//if (elementData.Tag == DicomTag.TransferSyntaxUID)
//{
// elementData.ElementValue = string.Empty;
//}
if (elementData.Encoding == ElementDataType.BulkData)
{
// If elementData.Encoding is ElementDataType.BulkData, then the BulkDataUri is returned in elementData.ElementValue
Console.WriteLine($"BulkDataUri: {elementData.ElementValue}");
// Set the bulk data: four ways to do it
//
string rawImagePath = Path.Combine(LEAD_VARS.ImagesDir, "image2.jpg");
string pngImagePath = Path.Combine(LEAD_VARS.ImagesDir, "PngImage.png");
// Method 1: Setting the [BulkData] property
using (FileStream fs = new FileStream(rawImagePath, FileMode.Open))
{
using (MemoryStream ms = new MemoryStream())
{
fs.CopyTo(ms);
elementData.BulkData = ms.ToArray();
}
}
// Method 2: Calling SetBulkData() with a byte array
using (FileStream fs = new FileStream(rawImagePath, FileMode.Open))
{
using (MemoryStream ms = new MemoryStream())
{
fs.CopyTo(ms);
elementData.SetBulkData(ms.ToArray());
}
}
// Method 3
// Set the bulk data using a RasterImage
using (RasterCodecs codecs = new RasterCodecs())
{
using (Leadtools.RasterImage image = codecs.Load(pngImagePath))
{
// The second argument is optional and specifies the QFactor
elementData.SetBulkData(image, 2);
}
}
// Method 4
// In this example(image2.dcm) it is raw jpeg data
// For uncompressed DICOM data, pass the raw uncompressedData
using (FileStream fs = new FileStream(rawImagePath, FileMode.Open))
{
elementData.SetBulkData(fs);
}
}
return true;
}
public static void MyLoadJson()
{
string dicomPath = Path.Combine(LEAD_VARS.ImagesDir, "DICOM", "image2.dcm");
string jsonPath = Path.Combine(LEAD_VARS.ImagesDir, "DICOM", "image2.json");
using (DicomDataSet dsJson = new DicomDataSet())
{
dsJson.Load(dicomPath, DicomDataSetLoadFlags.None);
dsJson.SaveJson(jsonPath, DicomDataSetSaveJsonFlags.IgnoreBinaryData);
}
using (DicomDataSet ds = new DicomDataSet())
{
ds.LoadJson(jsonPath, DicomDataSetLoadJsonFlags.None, MyLoadJsonBeforeElementCallback, null);
}
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";
}
Leadtools.Dicom.Common.Extensions Namespace
[SetBulkData(byte[])]:../dco/Extensions-LoadBeforeElementData-SetBulkData(byte[]).md
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document